home *** CD-ROM | disk | FTP | other *** search
/ Freesoft 1997 May / Freesoft_1997-05_cd.bin / nerecenz / network, comunications / TTERM / TTPMACRO.TX_ / TTPMACRO.TX
Text File  |  1997-06-30  |  53KB  |  1,962 lines

  1.     TTPMACRO for Tera Term Pro
  2.     T. Teranishi
  3.  
  4.     Copyright (C) 1994-1997 T. Teranishi
  5.     All Rights Reserved.
  6.  
  7. -------------------------------------------------------------------------------
  8. INDEX
  9.  
  10. 1. Introduction
  11.  
  12. 2. Usage
  13.  
  14.   2.1 How to run a macro file
  15.   2.2 Comand line
  16.   2.3 How to associate "TTL" files with TTPMACRO.EXE
  17.  
  18. 3. Macro language "Tera Term Language (TTL)"
  19.  
  20.   3.1 Types
  21.   3.2 Formats of constants
  22.   3.3 Identifiers and reserved words
  23.   3.4 Variables
  24.   3.5 Expressions and operators
  25.   3.6 Line formats
  26.  
  27. 4. TTL command reference
  28.  
  29.   4.1 Communication commands
  30.   4.2 Control commands
  31.   4.3 String operation commands
  32.   4.4 File operation commands
  33.   4.5 Password commands
  34.   4.6 Miscellaneous commands
  35.  
  36. 5. Appendixes
  37.  
  38.   Appendix A    Error messages
  39.   Appendix B    About new-line characters
  40.  
  41. -------------------------------------------------------------------------------
  42. 1. Introduction
  43.  
  44. TTPMACRO is an interpreter of the macro language "Tera Term Language (TTL)",
  45. which controls Tera Term and provides various functions like auto dialing,
  46. auto login, and so on.
  47.  
  48. -------------------------------------------------------------------------------
  49. 2. Usage
  50.  
  51. ...............................................................................
  52. 2.1 How to run a macro file
  53.  
  54. The executable file TTPMACRO.EXE should be placed in the directory
  55. in which TTERMPRO.EXE exists.
  56.  
  57. There are two ways to run a macro file.
  58.  
  59. 1) From Tera Term.
  60.  
  61. To start TTPMACRO, select the [Control] Macro command and then the macro file
  62. in the Open Macro dialog box.
  63.  
  64. 2) From TTPMACRO.
  65.  
  66. The macro file can be specified as a parameter of the command line (shortcut
  67. link) of TTPMACRO. For example, if you want to run the macro file
  68. "DIALUP.TTL", specify the command line (shortcut link) like:
  69.  
  70.     TTPMACRO DIALUP.TTL
  71.  
  72. You can omit the file name extension ".TTL". If you omit the file name, the
  73. Open Macro dialog box appears. It's convenient to install icons (shortcuts)
  74. for the macro files you use frequently.
  75.  
  76. If you choose method 2), you can run Tera Term, after starting the TTPMACRO,
  77. by using the "connect" command in the macro file. See "4.1.5 connect".
  78.  
  79. While the macro is running, you can pause it, restart it, and stop it by
  80. pressing the appropriate buttons in the TTPMACRO dialog box.
  81.  
  82. ...............................................................................
  83. 2.2 Command line
  84.  
  85. TTPMACRO.EXE [/I] [/V] [<macro file> [<second param>] [<third param>]]
  86.  
  87. where:
  88.     /I    Start TTPMACRO in iconized state.
  89.     /V    Start TTPMACRO in hidden (invisible) state.
  90.         <macro file>    Macro filename.
  91.         <second param>    Character string stored in the system
  92.                 variable "param2".
  93.         <third param>    Character string stored in the system
  94.                 variable "param3".
  95.  
  96. See "3.4 Variables" for the system variables "param2" and "param3".
  97.  
  98. ...............................................................................
  99. 2.3 How to associate "TTL" files with TTPMACRO.EXE
  100.  
  101. To associate the file extention ".TTL" with TTPMACRO.EXE, do the
  102. following steps.
  103.  
  104. a) In Windows 95 or Windows NT 4.0
  105.   a-1) Execute the [View] Options command of Explorer.
  106.  
  107.   a-2) Select the "File Types" tab.
  108.  
  109.   a-3) Click the "New Type" button and specify items like the following.
  110.     Description of type:    Tera Term macro files
  111.     Associated extention:    TTL
  112.  
  113.   a-4) Click the "New" button and specify items like the following.
  114.     Action:    Execute
  115.     Application used to perform action:
  116.         "C:\Program Files\TTERMPRO\ttpmacro.exe" "%1"
  117.         (If Tera Term Pro is installed in C:\Program Files\TTERMPRO.)
  118.  
  119.   a-5) Close all the dialog boxes by clicking "OK" buttons.
  120.  
  121.  b) In Windows NT 3.51
  122.   b-1) Execute the [File] Associate command of File Manager.
  123.   
  124.   b-2) Specify items like the following and click the "OK" button.
  125.     Files with extention:    TTL
  126.     Associate with:    "C:\TTERMPRO\TTPMACRO.EXE" "%1"
  127.                 (If Tera Term Pro is installed in C:\TTERMPRO.)
  128.  
  129. -------------------------------------------------------------------------------
  130. 3. Macro language "Tera Term Language (TTL)"
  131.  
  132. TTL is a simple interpreted language like BASIC. To learn TTL quickly, study
  133. the sample macro files in the distribution package and the command reference
  134. in section 4.
  135.  
  136. ...............................................................................
  137. 3.1 Types
  138.  
  139. TTL have two kinds of data types:
  140.  
  141.     Integer
  142.         Signed 32 bit, from -2147483648 to 2147483647.
  143.  
  144.     Character string
  145.         A sequence containing any character except NUL.
  146.         The maximum length of a string is 255.
  147.  
  148. ...............................................................................
  149. 3.2 Formats of constants
  150.  
  151. 1) Integer-type constants
  152.  
  153.     A integer-type constant is expressed as a decimal number.
  154.  
  155.     Example:
  156.         123
  157.         -11
  158.  
  159. 2) String-type constants
  160.  
  161.     There are two ways of expressing a string-type constant.
  162.  
  163.     a) A character string quoted by ' or " (both sides must be same).
  164.  
  165.     Example:
  166.         'Hello, world'
  167.         "I can't do that"
  168.  
  169.     b) A single character expressed as a "#" followed by an ASCII code
  170.     (decimal number).
  171.         Note: Strings can not contain NUL (ASCII code 0) characters.
  172.  
  173.     Example:
  174.         #65        the character "A"
  175.         #13        the CR character
  176.  
  177.     Format a) and b) can be combined in one expression.
  178.  
  179.     Example:
  180.         'cat readme.txt'#13#10
  181.         'abc'#13#10'def'#13#10'ghi'
  182.  
  183. ...............................................................................
  184. 3.3 Identifiers and reserved words
  185.  
  186. 1) Variable identifiers
  187.  
  188. The first character must be an alphabetic (A-Z, a-z) or an underscore
  189. character "_". Subsequent characters can be alphabetic, underscore or numeric
  190. (0-9). Variable identifiers are not case sensitive. The maximum length is 32.
  191.  
  192.     Example:
  193.         VARIABLE
  194.         _flag
  195.  
  196. 2) Label identifiers
  197.  
  198. Label identifiers consist of alphabetic, underscore or numeric characters,
  199. and are not case sensitive. The maximum length is 32.
  200.  
  201.     Example:
  202.         label1
  203.         100
  204.  
  205. 3) Reserved words
  206.  
  207. The following words are reserved:
  208.  
  209. [Command]
  210.     bplusrecv, bplussend, changedir... (see the list in section 4.)
  211.  
  212. [Operator]
  213.     and, not, or, xor
  214.  
  215. [System variables]
  216.     inputstr, param2, param3, result, timeout
  217.  
  218. ...............................................................................
  219. 3.4 Variables
  220.  
  221. 1) User variables
  222.  
  223. Defined by user. The type of a variable is determined when a value
  224. (integer or string) is assigned to it for the first time. Once the type of
  225. the variable is determined, values of a different type can not be
  226. assigned to it.
  227.  
  228. 2) System variables
  229.  
  230. Each system variable has a predefined type and value. Used with particular
  231. commands.
  232.  
  233. Variables    Type    Initial value    Related commands
  234. ------------------------------------------------------------------------
  235. inputstr    string        ""    recvln, waitln, waitrecv,
  236.                     passwordbox, inputbox
  237. param2        string        *1    *1
  238. param3        string        *1    *1
  239. result        integer        0    recvln, wait, waitevent, waitln,
  240.                     waitrecv, str2int, strcompare,
  241.                     strlen, strscan, filereadln,
  242.                     filesearch, filestrseek, yesnobox
  243. timeout        integer        0    recvln, wait, waitevent, waitln,
  244.                     waitrecv
  245.  
  246.     *1 The second and third command line parameter of TTPMACRO. The first
  247.     parameter is the macro file name. See "2.2 Command line".
  248.  
  249. ...............................................................................
  250. 3.5 Expressions and operators
  251.  
  252. Expressions consist of constants, variables, operators, and parentheses.
  253. Constants and variables must be of the integer type. The value of an
  254. expression is also an integer. The value of a relational expression
  255. (formed using relational operators) is 0, if it is true, or 1 if false.
  256.  
  257. The following are operators:
  258.  
  259. Category    Precedence    Operators
  260. --------------------------------------------------------------
  261. unary        1, high        not
  262. multiplicative    2        *, /
  263. additive    3        +, -, or, xor
  264. relational    4, low        =, <>, <, >, <=, >=
  265.  
  266. ...............................................................................
  267. 3.6 Line formats
  268.  
  269. There are five kinds of line formats for macro files.
  270.  
  271. 1) Empty lines
  272.  
  273. Lines which have no character or contain only space and tab characters.
  274. They have no effect on the execution of the macro.
  275.  
  276. 2) Comment lines
  277.  
  278. Lines beginning with a ';' character. No effect on the execution of the macro.
  279.  
  280.     Example:
  281.         ; Tera Term Language
  282.  
  283. 3) Command lines
  284.  
  285. Lines containing a single command with parameters (the one exception is the
  286. "if" command (see 4.2.7)).
  287.  
  288.     Format:
  289.         <command> <parameter> ...
  290.     Example:
  291.         connect'myhost'
  292.         wait 'OK' 'ERROR'
  293.         if result=2 goto error
  294.         sendln 'cat'
  295.         pause A*10
  296.         end
  297.  
  298. 4) Assignment lines
  299.  
  300. Lines which contain an assignment statement.
  301.  
  302.     Format:
  303.         <Variable> = <Value (constant, variable, expression)>
  304.     Example:
  305.         A = 33
  306.         B = C        C must already have a value.
  307.         VAL = I*(I+1)
  308.         A=B=C        the value of B=C (0 for false, 1 for true) is
  309.                 assigned to A.
  310.         Error=0<J
  311.         Username='MYNAME'
  312.  
  313. 5) Label lines
  314.  
  315. Lines which begin with a ':' character followed by a label identifier.
  316.  
  317.     Format:
  318.         :<Label>
  319.     Example:
  320.         :dial
  321.         :100
  322.  
  323. -------------------------------------------------------------------------------
  324. 4. TTL command reference
  325.  
  326. Command index
  327.  
  328. New commands added for the current version are labeled by "** new **".
  329. Commands modified for the current version are labeled by "** changed **".
  330.  
  331. 4.1 Communication commands
  332.  
  333.     4.1.1 bplusrecv
  334.     4.1.2 bplussend
  335.     4.1.3 changedir
  336.     4.1.4 closett        ** changed **
  337.     4.1.5 connect        ** changed **
  338.     4.1.6 disconnect    ** new **
  339.     4.1.7 flushrecv        ** new **
  340.     4.1.8 gettitle        ** new **
  341.     4.1.9 kmtrecv
  342.     4.1.10 kmtsend
  343.     4.1.11 loadkeymap    ** new **
  344.     4.1.12 logclose
  345.     4.1.13 logopen
  346.     4.1.14 logpause
  347.     4.1.15 logstart
  348.     4.1.16 logwrite
  349.     4.1.17 quickvanrecv
  350.     4.1.18 quickvansend
  351.     4.1.19 recvln        ** new **
  352.     4.1.20 restoresetup    ** new **
  353.     4.1.21 send
  354.     4.1.22 sendbreak    ** new **
  355.     4.1.23 sendfile
  356.     4.1.24 sendln
  357.     4.1.25 setecho        ** new **
  358.     4.1.26 setsync        ** new **
  359.     4.1.27 settitle        ** new **
  360.     4.1.28 showtt        ** changed **
  361.     4.1.29 unlink        ** new **
  362.     4.1.30 wait
  363.     4.1.31 waitevent    ** new **
  364.     4.1.32 waitln        ** new **
  365.     4.1.33 waitrecv
  366.     4.1.34 xmodemrecv
  367.     4.1.35 xmodemsend
  368.     4.1.36 zmodemrecv
  369.     4.1.37 zmodemsend
  370.  
  371. 4.2 Control commands
  372.  
  373.     4.2.1 call
  374.     4.2.2 end
  375.     4.2.3 execcmnd
  376.     4.2.4 exit
  377.     4.2.5 for, next
  378.     4.2.6 goto
  379.     4.2.7 if, then, elseif, else, endif
  380.     4.2.8 include
  381.     4.2.9 pause
  382.     4.2.10 return
  383.     4.2.11 while, endwhile
  384.  
  385. 4.3 String operation commands
  386.  
  387.     4.3.1 str2int
  388.     4.3.2 strcompare
  389.     4.3.3 strconcat
  390.     4.3.4 strcopy
  391.     4.3.5 strlen
  392.     4.3.6 strscan
  393.  
  394. 4.4 File operation commands
  395.  
  396.     4.4.1 fileclose
  397.     4.4.2 fileconcat
  398.     4.4.3 filecopy
  399.     4.4.4 filecreate
  400.     4.4.5 filedelete
  401.     4.4.6 fileopen
  402.     4.4.7 filereadln
  403.     4.4.8 filerename
  404.     4.4.9 filesearch
  405.     4.4.10 fileseek
  406.     4.4.11 filestrseek
  407.     4.4.12 filewrite
  408.     4.4.13 filewriteln
  409.  
  410. 4.5 Password commands
  411.  
  412.     4.5.1 delpassword    ** new **
  413.     4.5.2 getpassword    ** new **
  414.     4.5.3 passwordbox
  415.  
  416. 4.6 Miscellaneous commands
  417.  
  418.     4.6.1 beep
  419.     4.6.2 closesbox        ** new **
  420.     4.6.3 exec
  421.     4.6.4 getdate
  422.     4.6.5 getenv        ** new **
  423.     4.6.6 gettime
  424.     4.6.7 inputbox
  425.     4.6.8 int2str
  426.     4.6.9 messagebox
  427.     4.6.10 setdate        ** new **
  428.     4.6.11 setdlgpos    ** new **
  429.     4.6.12 setenv        ** new **
  430.     4.6.13 settime        ** new **
  431.     4.6.14 show        ** changed **
  432.     4.6.15 statusbox    ** new **
  433.     4.6.16 yesnobox
  434.  
  435. ...............................................................................
  436. 4.1 Communication commands
  437.  
  438. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  439. 4.1.1 bplusrecv
  440.  
  441. Format:
  442.     bplusrecv
  443.  
  444. Causes Tera Term to receive a file from the host with the B-Plus protocol.
  445. Pauses until the end of the file transfer.
  446.  
  447. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  448. 4.1.2 bplussend
  449.  
  450. Format:
  451.     bplussend <filename>
  452.  
  453. Causes Tera Term to send the file <filename> to the host with the B-Plus
  454. protocol. Pauses until the end of the file transfer.
  455.  
  456. Example:
  457.     bplussend 'readme.txt'
  458.  
  459. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  460. 4.1.3 changedir
  461.  
  462. Format:
  463.     changedir <path>
  464.  
  465. Changes the current directory of Tera Term.
  466.  
  467. Example:
  468.     changedir 'c:\'
  469.  
  470. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  471. 4.1.4 closett        ** changed **
  472.  
  473. Format:
  474.     closett
  475.  
  476. Closes Tera Term and enters the unlinked state.
  477. In the unlinked state, the "connect" command can open a new
  478. Tera Term window and link TTPMACRO to it.
  479.  
  480. See also:
  481.     "4.1.5 connect"
  482.     "4.1.6 disconnect"
  483.     "4.1.29 unlink"
  484.  
  485. Example:
  486.     closett
  487.     connect 'host'
  488.  
  489. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  490. 4.1.5 connect        ** changed **
  491.  
  492. Format:
  493.     connect <command line parameters>
  494.  
  495. If TTPMACRO is not linked to Tera Term, this command runs Tera Term
  496. with <command line parameters>, and links it to TTPMACRO.
  497.  
  498. If TTPMACRO has already been linked to Tera Term and Tera Term is
  499. not connected to the host, this command causes Tera Term to connect
  500. to the host specified by <command line parameters>.
  501.  
  502. If TTPMACRO has already been linked to Tera Term and Tera Term has
  503. already been connected to the host, this command is ignored.
  504.  
  505. No other communication commands should be executed before the link is
  506. established.
  507.  
  508. See Tera Term help for the format of <command line parameters>.
  509.  
  510. See also:
  511.     "4.1.4 closett"
  512.     "4.1.6 disconnect"
  513.     "4.1.29 unlink"
  514.  
  515. Example:
  516.     connect ''            No command line parameter
  517.  
  518.     connect '/C=2'            Run Tera Term with parameter '/C=2'.
  519.  
  520.     connect 'foohost.foo.foo.jp'
  521.  
  522.     CommandLine = '111.111.11.11'
  523.     connect CommandLine
  524.  
  525. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  526. 4.1.6 disconnect        ** new **
  527.  
  528. Format:
  529.     disconnect
  530.  
  531. Closes the communication between Tera Term and the host.
  532. If Tera Term is not terminated by this command, the link between Tera Term
  533. and TTPMACRO is kept.
  534.  
  535. See also:
  536.     "4.1.4 closett"
  537.     "4.1.5 connect"
  538.     "4.1.29 unlink"
  539.  
  540. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  541. 4.1.7 flushrecv        ** new **
  542.  
  543. Format:
  544.     flushrecv
  545.  
  546. Clears received characters in the buffer of TTPMACRO.
  547.  
  548. Characters received from the host are transfered to TTPMACRO.
  549. TTPMACRO stores the characters in the buffer and character-reading
  550. commands, such as the "wait" command, read out them from the buffer.
  551. Characters in the buffer are kept until character-reading
  552. commands process them or the buffer overflows.
  553.  
  554. The "flushrecv" command can be used to avoid unexpected results of
  555. character-reading commands caused by old characters in the buffer.
  556.  
  557. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  558. 4.1.8 gettitle        ** new **
  559.  
  560. Format:
  561.     gettitle <strvar>
  562.  
  563. Retrieves the title text of Tera Term and stores it in the string
  564. variable <strvar>.
  565.  
  566. Example:
  567.     gettitle titletext
  568.  
  569. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  570. 4.1.9 kmtrecv
  571.  
  572. Format:
  573.     kmtrecv
  574.  
  575. Causes Tera Term to receive a file from the host with the Kermit protocol.
  576. Pauses until the end of the file transfer.
  577.  
  578. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  579. 4.1.10 kmtsend
  580.  
  581. Format:
  582.     kmtsend <filename>
  583.  
  584. Causes Tera Term to send the file <filename> to the host with the Kermit
  585. protocol. Pauses until the end of the file transfer.
  586.  
  587. Example:
  588.     kmtsend 'readme.txt'
  589.  
  590. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  591. 4.1.11 loadkeymap        ** new **
  592.  
  593. Format:
  594.     loadkeymap <filename>
  595.  
  596. Causes Tera Term to load a keyboard setup file specified by <filename>.
  597.  
  598. Example:
  599.     loadkeymap 'keyboard.cnf'
  600.  
  601. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  602. 4.1.12 logclose
  603.  
  604. Format:
  605.     logclose
  606.  
  607. Causes Tera Term to close the log file.
  608.  
  609. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  610. 4.1.13 logopen
  611.  
  612. Format:
  613.     logopen <filename> <binary flag> <append flag>
  614.  
  615. Causes Tera Term to start logging. Received characters are written to the file
  616. <filename>.
  617.  
  618. If <binary flag> is zero, received new-line characters are converted (CR ->
  619. CR/CRLF) and escape sequences are stripped out. If <binary flag> is non-zero,
  620. received characters are written without any modifications.
  621.  
  622. If <append flag> is non-zero and the file <filename> already exists, received
  623. characters are appended to it. If <append flag> is zero and the file <filename>
  624. already exists, the file is overwritten.
  625.  
  626. Example:
  627.     logopen 'myhost.log' 0 0
  628.  
  629. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  630. 4.1.14 logpause
  631.  
  632. Format:
  633.     logpause
  634.  
  635. Causes Tera Term to pause logging. Received characters are discarded while
  636. logging is paused.
  637.  
  638. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  639. 4.1.15 logstart
  640.  
  641. Format:
  642.     logstart
  643.  
  644. Causes Tera Term to restart the logging, if paused.
  645.  
  646. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  647. 4.1.16 logwrite
  648.  
  649. Format:
  650.     logwrite <string>
  651.  
  652. Appends a <string> to the log file of the Tera Term.
  653.  
  654. This command is valid only while Tera Term is logging. The <string> can be
  655. written even while logging is paused.
  656.  
  657. Example:
  658.     logwrite 'LOG FILE'#13#10
  659.  
  660. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  661. 4.1.17 quickvanrecv
  662.  
  663. Format:
  664.     quickvanrecv
  665.  
  666. Causes Tera Term to receive a file from the host with the Quick-VAN protocol.
  667. Pauses until the end of the file transfer.
  668.  
  669. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  670. 4.1.18 quickvansend
  671.  
  672. Format:
  673.     quickvansend <filename>
  674.  
  675. Causes Tera Term to send the file <filename> to the host with the Quick-VAN
  676. protocol. Pauses until the end of the file transfer.
  677.  
  678. Example:
  679.     quickvansend 'readme.txt'
  680.  
  681. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  682. 4.1.19 recvln        ** new **
  683.  
  684. Format:
  685.     recvln
  686.  
  687. Retrieves a line of received characters from the host and stores it in
  688. the system variable "inputstr".
  689.  
  690. This command waits until a line is received or the communication
  691. between Tera Term and the host is terminated or the timeout occurs.
  692. If the system variable "timeout" is greater than zero, the timeout occurs
  693. when <timeout> seconds have passed. If the "timeout" is less than or equal
  694. to zero, the timeout never occurs.
  695.  
  696. If the line is received successfully, the system variable "result"
  697. is set to 1. Otherwise, "result" is set to zero.
  698.  
  699. Example:
  700.     fileopen file 'log.txt' 0        open the log file
  701.     setsync 1                    enter synchronous mode
  702.     result=1
  703.     while result=1
  704.         recvln                receive one line
  705.         filewriteln file inputstr    write it to the log file
  706.     endwhile
  707.     setsync 0                    enter asynchronous mode
  708.  
  709. See also "4.1.26 setsync" for the synchronous mode.
  710.  
  711. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  712. 4.1.20 restoresetup        ** new **
  713.  
  714. Format:
  715.     restoresetup <filename>
  716.  
  717. Causes Tera Term to load a Tera Term setup file specified by <filename>.
  718.  
  719. Example:
  720.     restoresetup 'teraterm.ini'
  721.  
  722. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  723. 4.1.21 send
  724.  
  725. Format:
  726.     send <data1> <data2> ....
  727.  
  728. Causes Tera Term to send characters to the host.
  729.  
  730. If <data> is a string, the string is sent to the host. If <data> is an
  731. integer, its lowest-order byte (0-255) is regarded as an ASCII code of the
  732. character, and the character is sent to the host.
  733.  
  734. Example:
  735.     send 'ABC'
  736.  
  737.     send  65 66 67        Send 'ABC'.
  738.                 (ASCII code of the character "A" is 65.)
  739.  
  740.     myname='Tera Term'
  741.     send 'My name is ' myname '.'
  742.  
  743. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  744. 4.1.22 sendbreak        ** new **
  745.  
  746. Format:
  747.     sendbreak
  748.  
  749. Causes Tera Term to send a break signal to the host.
  750.  
  751. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  752. 4.1.23 sendfile
  753.  
  754. Format:
  755.     sendfile <filename> <binary flag>
  756.  
  757. Causes Tera Term to send the file <filename> to the host. Pauses until the end
  758. of the file transfer.
  759.  
  760. If <binary flag> is non-zero, the file is sent without any modifications.
  761. If <binary flag> is zero, new-line characters are converted (CR -> CR/CRLF)
  762. and control characters except TAB, LF and CR are stripped out.
  763.  
  764. Example:
  765.     sendfile 'data.dat' 1
  766.  
  767. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  768. 4.1.24 sendln
  769.  
  770. Format:
  771.     sendln <data1> <data2> ....
  772.  
  773. Causes Tera Term to send characters followed by a new-line character to the
  774. host.
  775.  
  776. Format of <data> is the same as the "send" command (4.1.21).
  777.  
  778. Example:
  779.     sendln            Only a new-line character is sent.
  780.  
  781.     sendln 'abc'
  782.  
  783.     Password='mypassword'
  784.     sendln Password
  785.  
  786. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  787. 4.1.25 setecho        ** new **
  788.  
  789. Format:
  790.     setecho <echo flag>
  791.  
  792. Changes the local echo status of Tera Term.
  793. If <echo flag> is non-zero, the local echo is turned on.
  794. If <echo flag> is zero, the local echo is turned off.
  795.  
  796. Example:
  797.     setecho 1        local echo on
  798.  
  799. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  800. 4.1.26 setsync        ** new **
  801.  
  802. Format:
  803.     setsync <sync flag>
  804.  
  805. Enters the synchronous communication mode if <sync flag> is non-zero,
  806. or enters the asynchronous communication mode if <sync flag> is zero.
  807.  
  808. Tera Term transfers received characters from the host to TTPMACRO.
  809. TTPMACRO stores the characters in the buffer. The character-reading commands,
  810. such as the "wait" command, read out the characters from the buffer.
  811.  
  812. Initially, TTPMACRO is in the asynchronous mode. In this mode, the buffer may
  813. overflow if no character-reading command is executed for a long time, or the
  814. receiving speed is too fast.
  815.  
  816. In the synchronous mode, the buffer never overflows. If the buffer becomes
  817. full, Tera Term stops receiving characters from the host and stops transfering
  818. them to TTPMACRO. When the buffer regains enough space, Tera Term restarts
  819. receiving and transfering.
  820.  
  821. Enter the synchronous mode only when it is necessary and re-enter the
  822. asynchronous mode when the synchronous operation is no longer needed.
  823.  
  824. For a macro operation which requires reliability, something like processing
  825. lines of received characters without loss of data, you need to enter the
  826. synchronous mode. However, the synchronous mode makes Tera Term slow in speed
  827. of receiving characters and causes Tera Term freeze if no character-reading
  828. command is executed for a long time. On the other hand, a simple macro
  829. operation, such as auto login, works with almost no problem in the
  830. asynchronous mode, because the buffer size is large engough (4096 bytes) and
  831. all received characters are processed by character-reading commands before
  832. the buffer overflows.
  833.  
  834. See also "4.1.7 flushrecv" for clearing the buffer.
  835.  
  836. Example:
  837.     setsync 1        enter the synchronous mode
  838.     setsync 0        enter the asynchromous mode
  839.  
  840. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  841. 4.1.27 settitle        ** new **
  842.  
  843. Format:
  844.     settitle <title>
  845.  
  846. Changes the title text of Tera Term to <title>.
  847.  
  848. Example:
  849.     settitle 'Tera Term'
  850.  
  851. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  852. 4.1.28 showtt        ** changed **
  853.  
  854. Format:
  855.     showtt <show flag>
  856.  
  857. Minimizes Tera Term if <show flag> is zero.
  858. Restores Tera Term if <show flag> is greater than zero.
  859. Hides Tera Term if <show flag> is less than zero.
  860.  
  861. Example:
  862.     showtt 0        Minimize Tera Term.
  863.     showtt 1        Restore Tera Term.
  864.     showtt -1        Hide Tera Term.
  865.  
  866. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  867. 4.1.29 unlink        ** new **
  868.  
  869. Format:
  870.     unlink
  871.  
  872. Terminates the link between the current Tera Term window and TTPMACRO.
  873. TTPMACRO enters the unlinked state and can not controll the
  874. Tera Term window any more.
  875.  
  876. In the unlinked state, the "connect" command can open a new Tera Term
  877. window and link TTPMACRO to it.
  878.  
  879. See also:
  880.     "4.1.4 closett"
  881.     "4.1.5 connect"
  882.     "4.1.6 disconnect"
  883.  
  884. Example:
  885.     connect 'host1'        open a Tera Term window and link TTPMACRO to it
  886.     unlink            terminate the link
  887.     connect 'host2'        open another Tera Term window and link TTPMACRO to it
  888.  
  889. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  890. 4.1.30 wait
  891.  
  892. Format:
  893.     wait <string1> <string2> ...
  894.  
  895. Pauses until one of the character strings is received from the host,
  896. or until the timeout occurs. Maximum number of the strings is 10.
  897.  
  898. If the system variable "timeout" is greater than zero, the timeout occurs
  899. when <timeout> seconds have passed. If the "timeout" is less than or equal to
  900. zero, the timeout never occurs.
  901.  
  902. The "wait" command returns one of the following values in the system variable
  903. "result":
  904.  
  905.     Value        Meaning
  906.     -------------------------------------------------------
  907.     0        Timeout. No string has received.
  908.     1        <string1> has received.
  909.     2        <string2> has received.
  910.     .            .
  911.     .            .
  912.     .            .
  913.  
  914. Example:
  915.     timeout = 30            The timeout limit is 30 sec.
  916.     wait 'OK' 'ERROR'        Wait until 'OK' or 'ERROR' has
  917.                     received.
  918.     if result=0 goto timeout    If timeout occurs, go to ':timeout'.
  919.     if result=1 goto ok        If 'OK' has received, go to ':ok'.
  920.     if result=2 goto error
  921.  
  922.     wait #10'>' 'complete.'#13    Wait a line beginning with the ">" or
  923.                     a line ending with the "complete.".
  924.                     (ASCII code of LF is 10, and CR is 13.)
  925.  
  926. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  927. 4.1.31 waitevent        ** new **
  928.  
  929. Format:
  930.     waitevent <events>
  931.  
  932. Pauses until one of the events specified by <events> occurs.
  933.  
  934. <events> can be combination of the following event identifiers.
  935.  
  936. Event            Event identifier
  937. ---------------------------------
  938. timeout            1
  939. unlink            2
  940. disconnection    4
  941. connection        8
  942.  
  943. The timeout event occurs when <timeout> seconds have passed.
  944. <timeout> is the value of the system variable "timeout".
  945. If <timeout> is less than or equal to zero, this event never occurs.
  946.  
  947. The unlink event occurs when Tera Term is closed.
  948.  
  949. The disconnection (connection) event occurs when the
  950. communication between Tera Term and the host is closed (opend).
  951.  
  952. The "waitevent" command returns the identifier of the actual event
  953. in the system variable "result".
  954.  
  955. Example:
  956.     waitevent    4        Wait the disconnection event
  957.  
  958.     waitevent    2 or 8        Wait the unlink or connection events
  959.     if result=2 goto label1        The unlink event occured
  960.     if result=8 goto label2        The connection event occured
  961.  
  962. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  963. 4.1.32 waitln        ** new **
  964.  
  965. Format:
  966.     waitln <string1> <string2> ...
  967.  
  968. Pauses until a line which contains one of the character strings is received
  969. from the host, or until the timeout occurs. Maximum number of the strings
  970. is 10.
  971.  
  972. If the system variable "timeout" is greater than zero, the timeout occurs
  973. when <timeout> seconds have passed. If the "timeout" is less than or equal to
  974. zero, the timeout never occurs.
  975.  
  976. The "waitln" command returns the received line in the system variable
  977. "inputstr" and one of the following values in the system variable "result":
  978.  
  979.     Value        Meaning
  980.     -------------------------------------------------------
  981.     0        Timeout.
  982.     1        A line which contains <string1> has received.
  983.     2        A line which contains <string2> has received.
  984.     .            .
  985.     .            .
  986.     .            .
  987.  
  988. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  989. 4.1.33 waitrecv
  990.  
  991. Format:
  992.     waitrecv <sub-string> <len> <pos>
  993.  
  994. Pauses until a string, which satisfies a condition, is received from
  995. the host, or until the timeout occurs.
  996.  
  997. The condition is:
  998.     The length of the string is <len>, and the string contains
  999.     the <sub-string> beginning at the <pos>th character.
  1000.  
  1001. For example, if <sub-string> is "def" and <len> is 9 and <pos> is 4,
  1002. the string "abcdefghi" satisfies the condition.
  1003.  
  1004. If such a string is received, it is saved in the system variable "inputstr".
  1005.  
  1006. If the system variable "timeout" is greater than zero, the timeout occurs
  1007. when <timeout> seconds have passed. If the "timeout" is less than or equal
  1008. to zero, the timeout never occurs.
  1009.  
  1010. The "waitrecv" command returns one of the following values in the system
  1011. variable "result":
  1012.  
  1013. Value        Meaning
  1014. ----------------------------------------------------------------------------
  1015. -1        A string, which contains the <sub-string> beginning at the
  1016.         <pos>th character, has been received, and saved in the 
  1017.         "inputstr", but its length is less than <len> because of
  1018.         the timeout.
  1019.  
  1020. 0        Timeout. No string, which satisfies the condition, has
  1021.         been received.
  1022.  
  1023. 1        A string, which satisfies the condition, has been received,
  1024.         and saved in the "inputstr".
  1025.  
  1026. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1027. 4.1.34 xmodemrecv
  1028.  
  1029. Format:
  1030.     xmodemrecv <filename> <binary flag> <option>
  1031.  
  1032. Causes Tera Term to receive the file <filename> from the host with the XMODEM
  1033. protocol. Pauses until the end of the file transfer.
  1034.  
  1035. If the file is a binary file, <binary flag> must be non-zero. If the file is
  1036. a text file, <binary flag> must be zero.
  1037.  
  1038. <option> specifies the XMODEM option, and can be one of the following:
  1039.  
  1040.     <option>    XMODEM option
  1041.     --------------------------
  1042.     1        Checksum
  1043.     2        CRC
  1044.     3        1K
  1045.     others        Checksum
  1046.  
  1047. Example:
  1048.     xmodemrecv 'readme.txt' 0 2    XMODEM receive, text file, CRC
  1049.  
  1050. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1051. 4.1.35 xmodemsend
  1052.  
  1053. Format:
  1054.     xmodemsend <filename> <option>
  1055.  
  1056. Causes Tera Term to send the file <filename> to the host with the XMODEM
  1057. protocol. Pauses until the end of the file transfer.
  1058.  
  1059. <option> specifies the XMODEM option, and can be one of the following:
  1060.  
  1061.     <option>    XMODEM option
  1062.     --------------------------
  1063.     1        Checksum
  1064.     2        CRC
  1065.     3        1K
  1066.     others        Checksum
  1067.  
  1068. Example:
  1069.     xmodemsend 'readme.txt' 1    XMODEM send, checksum
  1070.  
  1071. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1072. 4.1.36 zmodemrecv
  1073.  
  1074. Format:
  1075.     zmodemrecv
  1076.  
  1077. Causes Tera Term to receive files from the host with the ZMODEM protocol.
  1078. Pauses until the end of the file transfer.
  1079.  
  1080. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1081. 4.1.37 zmodemsend
  1082.  
  1083. Format:
  1084.     zmodemsend <filename> <binary flag>
  1085.  
  1086. Causes Tera Term to send the file <filename> to the host with the ZMODEM
  1087. protocol. Pauses until the end of the file transfer.
  1088.  
  1089. If the file is a binary file, <binary flag> must be non-zero. If the file is
  1090. a text file, <binary flag> must be zero.
  1091.  
  1092. Example:
  1093.     zmodem 'readme.txt' 0
  1094.  
  1095. ...............................................................................
  1096. 4.2 Control commands
  1097.  
  1098. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1099. 4.2.1 call
  1100.  
  1101. Format:
  1102.     call <label>
  1103.  
  1104. Calls a subroutine beginning with the <label> line.
  1105.  
  1106. Example:
  1107.     messagebox "I'm in main." "test"
  1108.     call sub                Jump to ":sub".
  1109.     messagebox "Now I'm in main" "test"
  1110.     end
  1111.  
  1112.     :sub                    Start of the subroutine.
  1113.       messagebox "Now I'm in sub" "test"
  1114.       return                Go back to the main routine.
  1115.  
  1116. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1117. 4.2.2 end
  1118.  
  1119. Format:
  1120.     end
  1121.  
  1122. Quits the execution of the macro. TTPMACRO is also closed.
  1123.  
  1124. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1125. 4.2.3 execcmnd
  1126.  
  1127. Format:
  1128.     execcmnd <statement>
  1129.  
  1130. Executes a TTL statement expressed by the string <statement>.
  1131.  
  1132. Example:
  1133.     execcmnd "send 'abc'"        Execute the statement "send 'abc'".
  1134.  
  1135.     execcmnd "a=1"
  1136.  
  1137. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1138. 4.2.4 exit
  1139.  
  1140. Format:
  1141.     exit
  1142.  
  1143. Exits the include file and returns to the main file.
  1144.  
  1145. Example:
  1146.     See "4.2.8 include".
  1147.  
  1148. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1149. 4.2.5 for, next
  1150.  
  1151. Format:
  1152.     for <intvar> <first> <last>
  1153.       ...
  1154.       ...
  1155.     next
  1156.  
  1157. Repeats the statements between "for" and "next" until the integer variable
  1158. <intvar> has the value <last> at the 'next' statement.
  1159.  
  1160. The initial value of the <intvar> is <first>. If <last> is greater than
  1161. <first>, <intvar> is incremented by 1 at the 'next' line. If <last> is less
  1162. than <first>, <intvar> is decremented by 1 at the 'next' line.
  1163.  
  1164. Example:
  1165.     for i 1 10        Repeat ten times.
  1166.       sendln 'abc'
  1167.     next
  1168.  
  1169.     for i 5 1        Repeat five times.
  1170.       sendln 'abc'
  1171.     next
  1172.  
  1173. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1174. 4.2.6 goto
  1175.  
  1176. Format:
  1177.     goto <label>
  1178.  
  1179. Moves control to the next line of the <label>.
  1180.  
  1181. Example:
  1182.     goto label        Jump to the next line of the ':label'.
  1183.     ...
  1184.     ...
  1185.     ...
  1186.     :label
  1187.     send 'abc'
  1188.  
  1189. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1190. 4.2.7 if, then, elseif, else, endif
  1191.  
  1192. 1) Format:
  1193.     if <int> <statement>
  1194.  
  1195. Executes a <statement>, if <int> is non-zero.
  1196.  
  1197. Example:
  1198.     if A>1 goto label        If A>1, jump to ':label'.
  1199.  
  1200.     if result A=0            If result<>0, assign 0 to A.
  1201.  
  1202. 2) Format:
  1203.     if <int 1> then
  1204.       ...
  1205.       (Statements for the case:  <int 1> is true (non-zero).)
  1206.       ...
  1207.     [elseif <int 2> then]
  1208.       ...
  1209.       (Statements for the case:  <int 1> is false (zero) and
  1210.        <int 2> is true.)
  1211.       ...
  1212.       ...
  1213.     [elseif <int N> then]
  1214.       ...
  1215.       (Statements for the case:  <int 1>, <int 2>,... and
  1216.        <int N-1> are all false, and <int N> is true.)
  1217.       ...
  1218.     [else]
  1219.       ...
  1220.       (Statements for the case:  all the conditions above
  1221.        are false (zero).)
  1222.       ...
  1223.     endif
  1224.  
  1225. 'if' and 'elseif' statements must end with 'then'.
  1226. 'elseif' and 'else' can be omitted.
  1227. 'endif' can not be omitted.
  1228.  
  1229. Examples:
  1230.     if a=1 then
  1231.       b = 1
  1232.       c = 2
  1233.       d = 3
  1234.     endif
  1235.  
  1236.     if i<0 then
  1237.       i=0
  1238.     else
  1239.       i=i+1
  1240.     endif
  1241.  
  1242.     if i=1 then
  1243.       c = '1'
  1244.     elseif i=2 then
  1245.       c = '2'
  1246.     elseif i=3 then
  1247.       c = '3'
  1248.     else
  1249.       c = '?'
  1250.     endif
  1251.  
  1252. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1253. 4.2.8 include
  1254.  
  1255. Format:
  1256.     include <include file name>
  1257.  
  1258. Moves control to the include file.
  1259.  
  1260. Example:
  1261.     ----- main file 'main.ttl' ------
  1262.     i=10
  1263.     :loop
  1264.     include 'sub.ttl'        Move to the include file.
  1265.     if i>=0 goto loop
  1266.     end
  1267.     ----- End of 'main.ttl' ---------
  1268.  
  1269.     ----- include file 'sub.ttl' ----
  1270.     if i<0 then
  1271.       messagebox 'error!' 'sub'
  1272.       exit                Go back to the main file.
  1273.     endif
  1274.     i = i - 1
  1275.     ----- End of 'sub.ttl' ----------    Go back to the main file.
  1276.  
  1277. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1278. 4.2.9 pause
  1279.  
  1280. Format:
  1281.     pause <time>
  1282.  
  1283. Pauses for <time> seconds.
  1284.  
  1285. Example:
  1286.  
  1287.     pause 10    Pause for 10 seconds.
  1288.  
  1289.     pause Time
  1290.  
  1291. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1292. 4.2.10 return
  1293.  
  1294. Format:
  1295.     return
  1296.  
  1297. Exits the subroutine and returns to the main routine.
  1298.  
  1299. Example:
  1300.     See "4.2.1 call".
  1301.  
  1302. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1303. 4.2.11 while, endwhile
  1304.  
  1305. Format:
  1306.     while <int>
  1307.       ...
  1308.       ...
  1309.       ...
  1310.     endwhile
  1311.  
  1312. Repeats the statements between 'while' and 'endwhile' while <int> is non-zero.
  1313.  
  1314. Examples:
  1315.     i = 10
  1316.     while i>0
  1317.       i = i - 1    Repeat ten times.
  1318.     endwhile
  1319.  
  1320. ...............................................................................
  1321. 4.3 String operation commands
  1322.  
  1323. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1324. 4.3.1 str2int
  1325.  
  1326. Format:
  1327.     str2int <intvar> <string>
  1328.  
  1329. Converts the <string> which represents a decimal number to its numeric value.
  1330. The value is returned in the integer variable <intvar>. If the string is
  1331. converted successfully, the system variable "result" is set to 1. Otherwise,
  1332. "result" is set to zero.
  1333.  
  1334. Example:
  1335.     str2int val '123'        val=123, result=1
  1336.  
  1337.     str2int val '123abc'        result=0
  1338.  
  1339. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1340. 4.3.2 strcompare
  1341.  
  1342. Format:
  1343.     strcompare <string1> <string2>
  1344.  
  1345. Compares two strings. Depending on the relation between them, one of the
  1346. following result code is returned in the system variable "result":
  1347.  
  1348.     Relation        result
  1349.   ---------------------------------------
  1350.   <string1> < <string2>         -1
  1351.   <string1> = <string2>          0
  1352.   <string1> > <string2>          1
  1353.  
  1354. Example:
  1355.     strcompare 'abc' 'def'        result = -1
  1356.  
  1357.     strcompare command 'next'
  1358.     if result=0 goto label
  1359.     strcompare command 'end'
  1360.     if result=0 end
  1361.  
  1362. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1363. 4.3.3 strconcat
  1364.  
  1365. Format:
  1366.     strconcat <strvar> <string>
  1367.  
  1368. Appends a copy of <string> to the end of the string variable <strvar>.
  1369.  
  1370. Example:
  1371.     filename = 'c:\teraterm\'
  1372.     strconcat filename 'test.txt'
  1373.  
  1374. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1375. 4.3.4 strcopy
  1376.  
  1377. Format:
  1378.     strcopy <string> <pos> <len> <strvar>
  1379.  
  1380. Copies a substring of <string> to the string variable <strvar>.
  1381. The substring begings at the <pos>th character in <string>, and its length
  1382. is <len>.
  1383.  
  1384. Example:
  1385.     strcopy 'tera term' 6 4 substr        substr='term'
  1386.  
  1387. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1388. 4.3.5 strlen
  1389.  
  1390. Format:
  1391.     strlen <string>
  1392.  
  1393. Returns the length of <string> in the system variable "result".
  1394.  
  1395. Example:
  1396.     strlen 'abc'            result = 3
  1397.  
  1398. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1399. 4.3.6 strscan
  1400.  
  1401. Format:
  1402.     strscan <string> <substring>
  1403.  
  1404. Searches for <substring> in <string>.
  1405. If <substring> is found, its position is returned in the system variable
  1406. "result". If <string> contains more than one occurrence of <substring>,
  1407. the position of the first one is returned. If <substring> is not found,
  1408. "result" is set to zero.
  1409.  
  1410. Example:
  1411.     strscan 'tera term' 'term'        result = 6
  1412.  
  1413. ...............................................................................
  1414. 4.4 File operation commands
  1415.  
  1416. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1417. 4.4.1 fileclose
  1418.  
  1419. Format:
  1420.     fileclose <file handle>
  1421.  
  1422. Closes the file specified by <file handle>.
  1423. <file handle> is no longer valid after this command.
  1424.  
  1425. Example:
  1426.     fileclose fhandle
  1427.  
  1428. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1429. 4.4.2 fileconcat
  1430.  
  1431. Format:
  1432.     fileconcat <file1> <file2>
  1433.  
  1434. Appends a copy of file <file2> to the end of file <file1>.
  1435. <file1> and <file2> must not be same.
  1436.  
  1437. Example:
  1438.     fileconcat 'test.dat' test2.dat'
  1439.  
  1440. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1441. 4.4.3 filecopy
  1442.  
  1443. Format:
  1444.     filecopy <file1> <file2>
  1445.  
  1446. Copies file <file1> to file <file2>.
  1447. If <file2> already exists, it is overwritten. <file1> and <file2> must not
  1448. be same.
  1449.  
  1450. Example:
  1451.     filecopy 'test.dat' test2.dat'
  1452.  
  1453. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1454. 4.4.4 filecreate
  1455.  
  1456. Format:
  1457.     filecreate <file handle> <filename>
  1458.  
  1459. Creates and opens a new file specified by <filename>.
  1460. The file pointer is set to the beginning of the file. If file <filename>
  1461. already exists, its size is truncated to zero. If the file is successfully
  1462. created and opened, the file handle is returned in the integer variable
  1463. <file handle>. Otherwise, <file handle> is set to -1.
  1464.  
  1465. Example:
  1466.     filecreate fhandle 'data.dat'
  1467.  
  1468. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1469. 4.4.5 filedelete
  1470.  
  1471. Format:
  1472.     filedelete <filename>
  1473.  
  1474. Deletes the file specified by <filename>.
  1475.  
  1476. Example:
  1477.     filedelete 'temp.log'
  1478.  
  1479. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1480. 4.4.6 fileopen
  1481.  
  1482. Format:
  1483.     fileopen <file handle> <file name> <append flag>
  1484.  
  1485. Opens a file specified by <file name>.
  1486.  
  1487. If the file does not exist, it is created and then opened. If the file is
  1488. successfully opened, the file handle is returned in the integer variable
  1489. <file handle>. Otherwise, <file handle> is set to -1.
  1490.  
  1491. If <append flag> is zero, the file pointer is set to the beginning of the
  1492. file. If <append flag> is non-zero, the file pointer is set to the end of
  1493. the file.
  1494.  
  1495. Example:
  1496.     fileopen fhandle 'data.dat' 0
  1497.  
  1498.     fileopen fhandle 'data.dat' 1
  1499.  
  1500. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1501. 4.4.7 filereadln
  1502.  
  1503. Format:
  1504.     filereadln <file handle> <strvar>
  1505.  
  1506. Reads a line from the file specified by <file handle>.
  1507. The line is written into the string variable <strvar>. The file pointer
  1508. is moved to the beginning of the next line. If the file pointer reaches the
  1509. end of the file while reading the line, the system variable "result" is set
  1510. to 1. Otherwise, "result" is set to zero.
  1511.  
  1512. Example:
  1513.     fileopen fhandle 'test.txt' 0    Open a file.
  1514.     :loop
  1515.     filereadln fhandle line        Read a line from the file.
  1516.     if result goto fclose
  1517.     messagebox line 'test.txt'    Display the line.
  1518.     goto loop            Repeat until the end of the file.
  1519.     :fclose
  1520.     fileclose fhandle        Close the file.
  1521.  
  1522. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1523. 4.4.8 filerename
  1524.  
  1525. Format:
  1526.     filerename <file1> <file2>
  1527.  
  1528. Renames <file1> to <file2>.
  1529. <file1> and <file2> must not be same.
  1530.  
  1531. Example:
  1532.     filerename 'test.dat' test2.dat'
  1533.  
  1534. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1535. 4.4.9 filesearch
  1536.  
  1537. Format:
  1538.     filesearch <filename>
  1539.  
  1540. Searches for the file specified by <filename>.
  1541. If it is found, the system variable "result" is set to 1. Otherwise,
  1542. "result" is set to zero.
  1543.  
  1544. Example:
  1545.     filesearch 'readme.txt'
  1546.     if result=0 messagebox 'File not found.' 'error'
  1547.  
  1548. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1549. 4.4.10 fileseek
  1550.  
  1551. Format:
  1552.     fileseek <file handle> <offset> <origin>
  1553.  
  1554. Moves the pointer for the file specified by <file handle>.
  1555. With this command, the file pointer is moved <offset> bytes from:
  1556.  
  1557.     the beginning of the file, if <origin> is 0.
  1558.  
  1559.     the current position, if <origin> is 1.
  1560.  
  1561.     the end of the file, if <offset> is 2.
  1562.  
  1563. Example:
  1564.     fileseek fhandle 0 0    Move to the beginning of the file.
  1565.  
  1566.     fileseek fhandle 10 1    Move 10 bytes from the current position.
  1567.  
  1568.     fileseek fhandle 0 2    Move to the end of the file.
  1569.  
  1570. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1571. 4.4.11 filestrseek
  1572.  
  1573. Format:
  1574.     filestrseek <file handle> <string>
  1575.  
  1576. Searches for <string> in the file specified by <file handle>.
  1577. The search is started from the current position of the file pointer.
  1578.  
  1579. If <string> is found, the file pointer is moved to the next character of
  1580. the string, and the system variable "result" is set to 1. If <string> is
  1581. not found, the file pointer is not moved, and "result" is set to zero.
  1582.  
  1583. Example:
  1584.     fileopen fhandle 'teraterm.log' 0    Search for the string 'abc'
  1585.     filestrseek fhandle 'abc'        in the file 'teraterm.log'.
  1586.     if result=0 goto not_found
  1587.     filereadln fhandle str            Read characters from the next
  1588.                         of the 'abc' to the end of the
  1589.                         line.
  1590.     :not_found
  1591.     fileclose fhandle
  1592.  
  1593. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1594. 4.4.12 filewrite
  1595.  
  1596. Format:
  1597.     filewrite <file handle> <string>
  1598.  
  1599. Writes <string> to the file specified by <file handle>.
  1600.  
  1601. Example:
  1602.     filewrite fhandle '---------cut here---------'#13#10
  1603.  
  1604. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1605. 4.4.13 filewriteln
  1606.  
  1607. Format:
  1608.     filewriteln <file handle> <string>
  1609.  
  1610. Writes <string> and the new-line characters (CR+LF) to the file specified
  1611. by <file handle>.
  1612.  
  1613. Example:
  1614.     filewriteln fhandle '---------cut here---------'
  1615.  
  1616. ...............................................................................
  1617. 4.5 Password commands
  1618.  
  1619. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1620. 4.5.1 delpassword        ** new **
  1621.  
  1622. Format:
  1623.     delpassword <filename> <password name>
  1624.  
  1625. Deletes a password specified by <password name> in the password
  1626. file <filename>. If <password name> is a blank string,
  1627. all passwords in the file are deleted.
  1628.  
  1629. See "4.5.2 getpassword" for the password file.
  1630.  
  1631. Example:
  1632.     delpassword 'password.dat' 'mypassword'
  1633.  
  1634. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1635. 4.5.2 getpassword        ** new **
  1636.  
  1637. Format:
  1638.     getpassword <filename> <password name> <strvar>
  1639.  
  1640. Retrieves an encrypted password identified by <password name> from
  1641. the password file <filename>. Decrypts the password and stores it
  1642. into the string variable <strvar>.
  1643.  
  1644. If the specified file does not exist, it is newly created.
  1645. If the specified password is not stored in the file,
  1646. the password dialog box appears and the entered password
  1647. is sotred in <strvar>. At the same time, the new password
  1648. is encrypted and written in the file with the identifier
  1649. <password name>.
  1650.  
  1651. A password file can contain multiple passwords. Each of them
  1652. is identified by the password identifier.
  1653.  
  1654. Example:
  1655.     getpassword 'password.dat' 'mypassword' password
  1656.     connect 'myhost'
  1657.     wait 'login:'
  1658.     sendln 'myname'
  1659.     wait 'password:'
  1660.     sendln password
  1661.  
  1662. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1663. 4.5.3 passwordbox
  1664.  
  1665. Format:
  1666.     passwordbox <message> <title>
  1667.  
  1668. Displays a dialog box prompting the user to input a password.
  1669.  
  1670. The <message> is displayed in the dialog box. The <title> is displayed as the
  1671. dialog box title. The password typed by the user is not displayed as is.
  1672. Instead, asterisks are displayed. The password is returned in the system
  1673. variable "inputstr".
  1674.  
  1675. Example:
  1676.     passwordbox 'Enter password' 'Login'
  1677.  
  1678. ...............................................................................
  1679. 4.6 Miscellaneous commands
  1680.  
  1681. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1682. 4.6.1 beep
  1683.  
  1684. Format:
  1685.     beep
  1686.  
  1687. Makes a beep sound.
  1688.  
  1689. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1690. 4.6.2 closesbox        ** new **
  1691.  
  1692. Format:
  1693.     closesbox
  1694.  
  1695. Closes the status dialog box opend by the "statusbox" command.
  1696.  
  1697. Example:
  1698.     See "4.6.15 statusbox".
  1699. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1700. 4.6.3 exec
  1701.  
  1702. Format:
  1703.     exec <command line>
  1704.  
  1705. Runs an application specified by <command line>.
  1706.  
  1707. Format:
  1708.     exec 'notepad readme.txt'    Run "Notepad".
  1709.  
  1710. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1711. 4.6.4 getdate
  1712.  
  1713. Format:
  1714.     getdate <strvar>
  1715.  
  1716. Returns the current date in the string variable <strvar>, with the format
  1717. "YYYY-MM-DD".
  1718.  
  1719. Example:
  1720.     getdate datestr
  1721.  
  1722. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1723. 4.6.5 getenv        ** new **
  1724.  
  1725. Format:
  1726.     getenv <envname> <strvar>
  1727.  
  1728. Retrieves the value of an environment variable specifiedü@by <envname> and
  1729. stores it in the string variable <strvar>.
  1730.  
  1731. Example:
  1732.     getenv 'TEMP' env
  1733.  
  1734. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1735. 4.6.6 gettime
  1736.  
  1737. Format:
  1738.     gettime <strvar>
  1739.  
  1740. Returns the current time in the string variable <strvar>, with the format
  1741. "HH:MM:SS".
  1742.  
  1743. Example:
  1744.     gettime timestr
  1745.  
  1746. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1747. 4.6.7 inputbox
  1748.  
  1749. Format:
  1750.     inputbox <message> <title>
  1751.  
  1752. Displays a dialog box prompting user to input a string.
  1753.  
  1754. The <message> is displayed in the dialog box. The <title> is displayed as the
  1755. dialog box title. The string entered by the user is returned in the system
  1756. variable "inputstr".
  1757.  
  1758. Example:
  1759.     inputbox 'Password:' 'Login'
  1760.     sendln inputstr
  1761.  
  1762. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1763. 4.6.8 int2str
  1764.  
  1765. Format:
  1766.     int2str <strvar> <integer value>
  1767.  
  1768. Converts <integer value> to its string expression, and returns it in the
  1769. string variable <strvar>.
  1770.  
  1771. Example:
  1772.     int2str valstr 123        The string "123" is assigned to
  1773.                     the variable "valstr".
  1774.  
  1775. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1776. 4.6.9 messagebox
  1777.  
  1778. Format:
  1779.     messagebox <message> <title>
  1780.  
  1781. Displays a dialog box with <message> and <title>.
  1782.  
  1783. Example:
  1784.     messagebox ErrorMessage 'Error'
  1785.  
  1786. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1787. 4.6.10 setdate        ** new **
  1788.  
  1789. Format:
  1790.     setdate <date>
  1791.  
  1792. Sets the system date to <date>. The format of <date> should be "YYYY-MM-DD".
  1793.  
  1794. Example:
  1795.     setdate '1997-06-30'
  1796.  
  1797. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1798. 4.6.11 setdlgpos        ** new **
  1799.  
  1800. Format:
  1801.     setdlgpos <x> <y>
  1802.  
  1803. Changes the initial position for dialog boxes opend by the "inputbox",
  1804. "messagebox", "passwordbox" and "statusbox" commands. If the status dialog
  1805. box is displayed, the "setdlgpos" command also moves the dialog box.
  1806.  
  1807. <x> and <y> specify the position (x,y) in the screen coordinate.
  1808. The origin (0,0) is upper left corner of the screen.
  1809.  
  1810. Example:
  1811.     setdlgpos 0 0
  1812.     messagebox 'Message' 'Title'    message box at the upper left corner
  1813.  
  1814.     setdlgpos 0 200            open the status box
  1815.     statusbox 'Message' 'Title'
  1816.     for i 0 200
  1817.       setdlgpos i 200        moves the status box
  1818.     next
  1819.  
  1820. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1821. 4.6.12 setenv        ** new **
  1822.  
  1823. Format:
  1824.     setenv <env name> <env value>
  1825.  
  1826. Sets the environment variable specified by <env name> to the character
  1827. string <env value>.
  1828.  
  1829. Example:
  1830.     setenv 'WORK' 'c:\work'
  1831.  
  1832. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1833. 4.6.13 settime        ** new **
  1834.  
  1835. Format:
  1836.     settime <time>
  1837.  
  1838. Sets the system time to <time>. The format of <time> should be "HH:MM:SS".
  1839.  
  1840. Example:
  1841.     settime '01:05:00'
  1842.  
  1843. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1844. 4.6.14 show        ** changed **
  1845.  
  1846. Format:
  1847.     show <show flag>
  1848.  
  1849. Minimizes TTPMACRO, if <show flag> is zero.
  1850. Restores TTPMACRO, if <show flag> is greater than zero.
  1851. Hides TTPMACRO, if <show flag> is less than zero.
  1852.  
  1853. Example:
  1854.     show 0        Minimize TTPMACRO.
  1855.     show 1        Restore TTPMACRO.
  1856.     show -1        Hide TTPMACRO.
  1857.  
  1858. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1859. 4.6.15 statusbox        ** new **
  1860.  
  1861. Format:
  1862.     statusbox <message> <title>
  1863.  
  1864. Displays the status dialog box if it has not been displayed yet.
  1865. Changes the message to <message> and title to <title>.
  1866.  
  1867. The "setdlgpos" command (see 4.6.11) changes the position of status
  1868. dialog box.
  1869. The "closesbox" (see 4.6.2) command closes the status dialog box.
  1870.  
  1871. Example:
  1872.     setdlgpos 200 200            set the initial position
  1873.     statusbox 'Message' 'Title'        display the status dialog box
  1874.     pause 3    
  1875.     setdlgpos 0 0                move the dialog box
  1876.     pause 3
  1877.     closesbox                close the dialog box
  1878.  
  1879. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1880. 4.6.16 yesnobox
  1881.  
  1882. Format:
  1883.     yesnobox <message> <title>
  1884.  
  1885. Displays a dialog box with the <message>, <title>, "Yes" button and
  1886. "No" button.
  1887.  
  1888. If the user clicks on the "Yes" button, the system variable "result" is set
  1889. to 1.  If the user clicks on the "No" button, "result" is set to zero.
  1890.  
  1891. Example:
  1892.     yesnobox 'Try agian?' 'Tera Term'
  1893.     if result goto retry
  1894.     end
  1895.  
  1896. -------------------------------------------------------------------------------
  1897.  6. Appendixes
  1898.  
  1899. ...............................................................................
  1900. Appendix A    Error messages
  1901.  
  1902.  Error message                Meaning
  1903.  ----------------------------------------------------------------------------
  1904.  Can't call sub.        Cannot call the subroutine, the subroutine
  1905.                 is located in a different file.
  1906.  
  1907.  Can't link macro.        Failure to establish the link between
  1908.                 TTPMACRO and Tera Term.
  1909.  
  1910.  Can't open file.        The include file does not exist, or there are
  1911.                 too many nested include files.
  1912.  
  1913.  ")" expected.            A closing parenthesis does not exist where
  1914.                 it should.
  1915.  
  1916.  Link macro first.        The command cannot be executed before the
  1917.                 link between TTPMACRO and Tera Term is
  1918.                 established.
  1919.  
  1920.  Divide by zero.        The expression attempts to divide by zero.
  1921.  
  1922.  Invalid control.        Invalid use of "else", "elseif" or "endif".
  1923.  
  1924.  Label already defined.        Duplicate use of the label.
  1925.  
  1926.  Label required.        The label is not defined.
  1927.  
  1928.  Stack overflow.        There are too many nested subroutines,
  1929.                 "for-next" loops or "while-endwhile" loops.
  1930.  
  1931.  Syntax error.            The format of the statement is invalid.
  1932.  
  1933.  Too many labels.        TTPMACRO can not handle more than 256 labels.
  1934.  
  1935.  Too many variables.        TTPMACRO cannot handle more than 128 integer
  1936.                 variables and 128 string variables.
  1937.  
  1938.  Type mismatch.            The type of the constant or variable is
  1939.                 invalid.
  1940.  
  1941.  Variable not initialized.    The variable must be initialized before it is
  1942.                 referenced.
  1943.  
  1944. ...............................................................................
  1945. Appendix B    About new-line characters
  1946.  
  1947. New-line characters (CR or CR+LF) received from the host are converted to
  1948. CR+LF pairs by Tera Term, and then Tera Term sends them to TTPMACRO.
  1949.  
  1950. You should use the pair (CR+LF) as a new-line character to send to Tera Term.
  1951.  
  1952. ASCII code 13 (decimal) is for CR, and 10 is for LF.
  1953.  
  1954. Example:
  1955.   send 'abc'#13#10        Same as the statement "sendln 'abc'". The
  1956.                 actual new-line character to be sent to the
  1957.                 host is determined by Tera Term.
  1958.  
  1959.   wait #10'abc' 'def'#13    Waits for a line beginning with "abc",
  1960.                 or a line ending with 'def'.
  1961.  
  1962.   logwrite 'abc'#13#10        Writes line "abc" to the log file.